/* This do file is the master file that runs all the other do files. 
   To run this code, change the global "path" on line 18 to reflect the 
   location on the user's machine that contain the files to replicate the study.
   The "path" is the directory where the is the main folder.
*/

* Set Stata version
version 18.0

* Clear memory
clear all
set more off
program drop _all
macro drop _all
capture log close

*Set folder
global path = "C:\Users\75618rpo\Dropbox\Research\Literature Latex\Corruption, accountability and voting\Submission R&R JoP\Replication\replication_package_JOP"
cd "$path"

* Create log file
log using "${path}\cleaning_running.log", replace

* Install packages
capture ssc install estout
capture ssc install balancetable

* Code files

local code_main_estimations					"main_estimations.do"
local code_Appendix_C						"Appendix_C.do"
local code_analysis_polls					"analysis_polls.do"
local code_analysis_extras					"analysis_extras.do"
local code_Appendix_D						"Appendix_D.do"


********************************************************************************

* Switches: these control which parts of the data cleaning & running code you will re-run.
* Also, each do file can be ran independently.
#delimit ;
local switches_all
	main_estimations
	Appendix_C
	analysis_polls
	analysis_extras
	Appendix_D 
;
#delimit cr

local switch_main_estimations				= 1
local switch_Appendix_C						= 1
local switch_analysis_polls					= 1
local switch_analysis_extras				= 1
local switch_Appendix_D						= 1 

********************************************************************************

// Start timer
timer on 1

foreach switch of local switches_all {
	if `switch_`switch'' {
		cd "${code_cleaning}"
		do `code_`switch''
	}
}

* End timer
timer off 1
timer list 1

* Close log file
log close
